/**
 * 
 */
package weibo4j.examples;

import weibo4j.Search;
import weibo4j.Users;
import weibo4j.examples.oauth2.Log;
import weibo4j.http.HttpClient;
import weibo4j.model.PostParameter;
import weibo4j.model.WeiboException;
import weibo4j.org.json.JSONArray;
import weibo4j.org.json.JSONObject;
import weibo4j.util.WeiboConfig;

/**
 * 注册
 * @author Administrator
 * 
 */
public class WeiboSearch {
	
	//搜索某一话题下的微博,关键词只能为两#间的话题，即只能搜索某话题下的微博
	//只返回最新200条结果 ,count每页10－50条
	public static JSONArray topics(String access_token,String topic,int count,int page){
		JSONArray result = null;
		try {
			HttpClient client = new HttpClient();
			client.setToken(access_token);
			result=client.get(WeiboConfig.getValue("baseURL")+"search/topics.json",new PostParameter[]{
				new PostParameter("q", topic),
				new PostParameter("count", count),new PostParameter("page", page)
			}).asJSONArray();
			Log.logInfo(result.toString());
		} catch (WeiboException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String access_token = WeiboContants.access_token;
		String uid =WeiboContants.uid;
		String domain =WeiboContants.domain;
		topics(access_token,"cto",50,4);
	}

}
